<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/favicon.ico">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon.ico">
  <link rel="mask-icon" href="/images/favicon.ico" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"blog.upup.fun","root":"/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="前阵子开发了个听音乐的软件Music Free，这里简单记录一下给软件开发插件的步骤。">
<meta property="og:type" content="article">
<meta property="og:title" content="开发MusicFree插件">
<meta property="og:url" content="http://blog.upup.fun/2022/09/15/%E5%BC%80%E5%8F%91MusicFree%E6%8F%92%E4%BB%B6/index.html">
<meta property="og:site_name" content="猫头猫">
<meta property="og:description" content="前阵子开发了个听音乐的软件Music Free，这里简单记录一下给软件开发插件的步骤。">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2022-09-15T14:34:45.000Z">
<meta property="article:modified_time" content="2022-10-02T15:55:19.642Z">
<meta property="article:author" content="猫头猫">
<meta property="article:tag" content="js">
<meta property="article:tag" content="语法">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://blog.upup.fun/2022/09/15/%E5%BC%80%E5%8F%91MusicFree%E6%8F%92%E4%BB%B6/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>开发MusicFree插件 | 猫头猫</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">猫头猫</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-works">

    <a href="/works/" rel="section"><i class="fa fa-smile fa-fw"></i>小作品</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://blog.upup.fun/2022/09/15/%E5%BC%80%E5%8F%91MusicFree%E6%8F%92%E4%BB%B6/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="猫头猫">
      <meta itemprop="description" content="如果我是一只小猫咪，每天只要喵喵叫。">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="猫头猫">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          开发MusicFree插件
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-09-15 22:34:45" itemprop="dateCreated datePublished" datetime="2022-09-15T22:34:45+08:00">2022-09-15</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%89%8D%E7%AB%AF/" itemprop="url" rel="index"><span itemprop="name">前端</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%89%8D%E7%AB%AF/%E5%AE%89%E5%8D%93/" itemprop="url" rel="index"><span itemprop="name">安卓</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>3.5k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>3 分钟</span>
            </span>
            <div class="post-description">前阵子开发了个听音乐的软件Music Free，这里简单记录一下给软件开发插件的步骤。</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="MusicFree插件是什么"><a href="#MusicFree插件是什么" class="headerlink" title="MusicFree插件是什么"></a>MusicFree插件是什么</h1><p>MusicFree是一个插件化的音乐播放器。它本身不包含任何音乐源，所有的功能都是通过插件的形式导入的。插件本质上是一个javascript函数，通过实现符合插件协议的javascript函数，即可完成特定音源的播放，这也就意味着只要能搜得到的音乐，那么就都可以播放。</p>
<h1 id="插件的标准协议"><a href="#插件的标准协议" class="headerlink" title="插件的标准协议"></a>插件的标准协议</h1><p>一个MusicFree插件的结构如下:</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// packages里面预置了一些常用的包，包括axios，dayjs，cryptojs和cheerio，应该够用了</span></span><br><span class="line"><span class="function"><span class="keyword">function</span> <span class="title">pluginName</span>(<span class="params">packages</span>)</span>&#123;</span><br><span class="line">    <span class="comment">// 在这里可以编写一些逻辑，存储全局变量之类的;</span></span><br><span class="line">    <span class="keyword">return</span> &#123;</span><br><span class="line">        <span class="attr">platform</span>: <span class="string">&#x27;插件名称&#x27;</span>, <span class="comment">// [必选] 插件名，这个名字没取好，于是将错就错了</span></span><br><span class="line">        <span class="attr">cacheControl</span>: <span class="string">&#x27;no-cache&#x27;</span>, <span class="comment">// [可选] 插件的缓存控制方案，用来缓存插件信息</span></span><br><span class="line">        <span class="attr">version</span>: <span class="string">&#x27;0.0.0&#x27;</span>, <span class="comment">// [可选] 插件版本号</span></span><br><span class="line">        <span class="attr">primaryKey</span>: [<span class="string">&#x27;id&#x27;</span>], <span class="comment">// [可选] 主键名，可在此字段中填写插件函数入参中必备的字段</span></span><br><span class="line">        <span class="attr">appVersion</span>: <span class="string">&#x27;&gt;0.0&#x27;</span>, <span class="comment">// [可选] 兼容此插件的app版本号，预防后续协议更新出现不兼容格式时报错的情况。</span></span><br><span class="line">        <span class="attr">defaultSearchType</span>: <span class="string">&#x27;music&#x27;</span>, <span class="comment">// [可选] 插件在搜索时，首屏默认请求的搜索类型。</span></span><br><span class="line">        <span class="comment">/** 搜索 */</span></span><br><span class="line">        <span class="attr">search</span>: <span class="function"><span class="keyword">function</span>(<span class="params">query, page, type</span>) </span>&#123; <span class="comment">// 三个参数分别为: 查询的keyword，当前页码，搜索类型</span></span><br><span class="line">            <span class="keyword">if</span>(type === <span class="string">&#x27;music&#x27;</span>) &#123;</span><br><span class="line">                <span class="comment">// 网络请求</span></span><br><span class="line">                <span class="keyword">return</span> &#123;</span><br><span class="line">                    <span class="attr">isEnd</span>: <span class="literal">true</span>, <span class="comment">// 分页请求是否结束</span></span><br><span class="line">                    <span class="attr">data</span>: [], <span class="comment">// MusicItem类型的列表</span></span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span>(type === <span class="string">&#x27;album&#x27;</span>) &#123;</span><br><span class="line">                <span class="comment">// 网络请求</span></span><br><span class="line">                <span class="keyword">return</span> &#123;</span><br><span class="line">                    <span class="attr">isEnd</span>: <span class="literal">true</span>, <span class="comment">// 分页请求是否结束</span></span><br><span class="line">                    <span class="attr">data</span>: [], <span class="comment">// AlbumItem类型的列表</span></span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span>(type === <span class="string">&#x27;artist&#x27;</span>) &#123;</span><br><span class="line">                <span class="comment">// 网络请求</span></span><br><span class="line">                <span class="keyword">return</span> &#123;</span><br><span class="line">                    <span class="attr">isEnd</span>: <span class="literal">true</span>, <span class="comment">// 分页请求是否结束</span></span><br><span class="line">                    <span class="attr">data</span>: [], <span class="comment">// ArtistItem类型的列表</span></span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;,</span><br><span class="line">        <span class="comment">/** 获取真实的播放源 */</span></span><br><span class="line">        <span class="attr">getMediaSource</span>: <span class="function"><span class="keyword">function</span> (<span class="params">musicItem</span>) </span>&#123; <span class="comment">// 入参：搜索结果中MusicItem类型的音乐</span></span><br><span class="line">            <span class="keyword">return</span> &#123;</span><br><span class="line">                <span class="attr">headers</span>: <span class="literal">undefined</span>, <span class="comment">// [可选] headers</span></span><br><span class="line">                <span class="attr">url</span>: <span class="string">&#x27;https://&#x27;</span>, <span class="comment">// 真实url,</span></span><br><span class="line">                <span class="attr">userAgent</span>: <span class="literal">undefined</span>, <span class="comment">// [可选] 如果不填，会取headers的user-agent字段</span></span><br><span class="line">                </span><br><span class="line">            &#125;</span><br><span class="line">        &#125;,</span><br><span class="line">        <span class="comment">/** 根据mediaBase信息（包括primaryKey） 获取歌曲的详细信息 [!!此函数暂时用不到 ] */</span></span><br><span class="line">        <span class="attr">getMusicInfo</span>: <span class="function"><span class="keyword">function</span> (<span class="params">mediaBase</span>) </span>&#123;</span><br><span class="line">            <span class="keyword">return</span> musicItem;</span><br><span class="line">        &#125;,</span><br><span class="line">        <span class="comment">/** 获取歌词 */</span></span><br><span class="line">        <span class="attr">getLyric</span>: <span class="function"><span class="keyword">function</span> (<span class="params">musicItem</span>)</span>&#123;</span><br><span class="line"></span><br><span class="line">            <span class="keyword">return</span> &#123;</span><br><span class="line">                <span class="attr">lrc</span>: <span class="string">&#x27;http:///&#x27;</span>, <span class="comment">//歌词源,</span></span><br><span class="line">                <span class="attr">rawLrc</span>: <span class="string">&#x27;[00:00.000]这是一句歌词&#x27;</span>, <span class="comment">//纯文本的歌词</span></span><br><span class="line">            &#125;</span><br><span class="line">        &#125;,</span><br><span class="line">        <span class="comment">/** 获取专辑详细信息 */</span></span><br><span class="line">        <span class="attr">getAlbumInfo</span>: <span class="function"><span class="keyword">function</span> (<span class="params">albumItem</span>) </span>&#123;</span><br><span class="line"></span><br><span class="line">            <span class="keyword">return</span> &#123;</span><br><span class="line">                ...albumItem,</span><br><span class="line">                <span class="attr">musicList</span>: []</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;,</span><br><span class="line">        <span class="comment">/** 查询作者的详细信息 */</span></span><br><span class="line">        <span class="attr">queryArtistWorks</span>: <span class="function"><span class="keyword">function</span> (<span class="params">artistItem, page, type</span>) </span>&#123;</span><br><span class="line">            <span class="keyword">if</span>(type === <span class="string">&#x27;music&#x27;</span>) &#123;</span><br><span class="line">                <span class="comment">// 网络请求</span></span><br><span class="line">                <span class="keyword">return</span> &#123;</span><br><span class="line">                    <span class="attr">isEnd</span>: <span class="literal">false</span>,</span><br><span class="line">                    <span class="attr">data</span>: [], <span class="comment">// MusicItem类型音乐列表</span></span><br><span class="line">                &#125;</span><br><span class="line">            &#125; </span><br><span class="line">            <span class="keyword">if</span>(type === <span class="string">&#x27;album&#x27;</span>) &#123;</span><br><span class="line">                <span class="comment">// 网络请求</span></span><br><span class="line">                <span class="keyword">return</span> &#123;</span><br><span class="line">                    <span class="attr">isEnd</span>: <span class="literal">false</span>,</span><br><span class="line">                    <span class="attr">data</span>: [], <span class="comment">// AlbumItem类型音乐列表</span></span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;,</span><br><span class="line">        <span class="comment">/** 导入单曲 */</span></span><br><span class="line">        <span class="attr">importMusicItem</span>: <span class="function"><span class="keyword">function</span> (<span class="params">urlLike</span>) </span>&#123;</span><br><span class="line">            <span class="keyword">return</span> musicItem;</span><br><span class="line">        &#125;,</span><br><span class="line">        <span class="comment">/** 导入歌单 */</span></span><br><span class="line">        <span class="attr">importMusicSheet</span>: <span class="function"><span class="keyword">function</span> (<span class="params">urlLike</span>) </span>&#123;</span><br><span class="line">            <span class="keyword">const</span> musicItems = [];</span><br><span class="line">            <span class="keyword">return</span> musicItems;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>目前插件中的所有常量/函数如上，只有platform是必选参数，其他均为可选。</p>
<p>插件中定义了四种基本的媒体类型，分别是:</p>
<ul>
<li><p>基础媒体类型：platform和id标识着唯一的一个媒体</p>
<figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">type</span> IMediaBase = &#123;</span><br><span class="line">    <span class="attr">id</span>: <span class="built_in">string</span>;</span><br><span class="line">    platform: <span class="built_in">string</span>;</span><br><span class="line">    $?: <span class="built_in">any</span>; <span class="comment">// 内部变量，不要给它赋值，会被覆盖</span></span><br><span class="line">    [k: symbol]: <span class="built_in">any</span>;</span><br><span class="line">    [k: <span class="built_in">string</span>]: <span class="built_in">any</span>;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>
</li>
<li><p>音乐类型</p>
<figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">interface</span> IMusicItemBase <span class="keyword">extends</span> ICommon.IMediaBase &#123;</span><br><span class="line">    <span class="comment">/** 其他属性 */</span></span><br><span class="line">    [k: keyof IMusicItem]: IMusicItem[k];</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">interface</span> IMusicItem &#123;</span><br><span class="line">    <span class="comment">/** 歌曲在平台的唯一编号 */</span></span><br><span class="line">    <span class="attr">id</span>: <span class="built_in">string</span>;</span><br><span class="line">    <span class="comment">/** 平台 */</span></span><br><span class="line">    platform: <span class="built_in">string</span>;</span><br><span class="line">    <span class="comment">/** 作者 */</span></span><br><span class="line">    artist: <span class="built_in">string</span>;</span><br><span class="line">    <span class="comment">/** 标题 */</span></span><br><span class="line">    title: <span class="built_in">string</span>;</span><br><span class="line">    <span class="comment">/** 时长(s) */</span></span><br><span class="line">    duration: <span class="built_in">number</span>;</span><br><span class="line">    <span class="comment">/** 专辑名 */</span></span><br><span class="line">    album: <span class="built_in">string</span>;</span><br><span class="line">    <span class="comment">/** 专辑封面图 */</span></span><br><span class="line">    artwork: <span class="built_in">string</span>;</span><br><span class="line">    <span class="comment">/** 音源 */</span></span><br><span class="line">    url?: <span class="built_in">string</span>;</span><br><span class="line">    <span class="comment">/** 歌词URL */</span></span><br><span class="line">    lrc?: <span class="built_in">string</span>;</span><br><span class="line">    <span class="comment">/** 歌词 */</span></span><br><span class="line">    rawLrc?: <span class="built_in">string</span>;</span><br><span class="line">    <span class="comment">/** 其他可以被序列化的信息 */</span></span><br><span class="line">    [k: <span class="built_in">string</span>]: <span class="built_in">any</span>;</span><br><span class="line">    <span class="comment">/** 内部信息 */</span></span><br><span class="line">    [k: symbol]: <span class="built_in">any</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>作者类型</p>
<figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">interface</span> IArtistItemBase <span class="keyword">extends</span> ICommon.IMediaBase &#123;</span><br><span class="line">    <span class="attr">name</span>: <span class="built_in">string</span>;</span><br><span class="line">    id: <span class="built_in">string</span>;</span><br><span class="line">    fans?: <span class="built_in">number</span>;</span><br><span class="line">    description?: <span class="built_in">string</span>;</span><br><span class="line">    platform: <span class="built_in">string</span>;</span><br><span class="line">    avatar: <span class="built_in">string</span>;</span><br><span class="line">    worksNum: <span class="built_in">number</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">interface</span> IArtistItem <span class="keyword">extends</span> IArtistItemBase &#123;</span><br><span class="line">    <span class="attr">musicList</span>: IMusic.IMusicItemBase;</span><br><span class="line">    albumList: IAlbum.IAlbumItemBase;</span><br><span class="line">    [k: <span class="built_in">string</span>]: <span class="built_in">any</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>专辑类型</p>
<figure class="highlight typescript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">interface</span> IAlbumItemBase <span class="keyword">extends</span> ICommon.IMediaBase &#123;</span><br><span class="line">    <span class="attr">artwork</span>: <span class="built_in">string</span>;</span><br><span class="line">    title: <span class="built_in">string</span>;</span><br><span class="line">    date: <span class="built_in">string</span>;</span><br><span class="line">    artist: <span class="built_in">string</span>;</span><br><span class="line">    description?: <span class="built_in">string</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">interface</span> IAlbumItem <span class="keyword">extends</span> IAlbumItemBase &#123;</span><br><span class="line">    <span class="attr">musicList</span>: IMusic.IMusicItem[];</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>
<p>通过编写以上简单的脚本，并通过musicfree的插件导入，就可以使用插件完成对应的音乐行为了。</p>

    </div>

    
    
    
        <div class="reward-container">
  <div>嘻嘻</div>
  <button onclick="var qr = document.getElementById('qr'); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
      
      <div style="display: inline-block;">
        <img src="/images/wechatpay.png" alt="猫头猫 微信支付">
        <p>微信支付</p>
      </div>
      
      <div style="display: inline-block;">
        <img src="/images/alipay.png" alt="猫头猫 支付宝">
        <p>支付宝</p>
      </div>

  </div>
</div>

        

  <div class="followme">
    <p>欢迎关注我的其它发布渠道</p>

    <div class="social-list">

        <div class="social-item">
          <a target="_blank" class="social-link" href="/images/wechat_channel.jpg">
            <span class="icon">
              <i class="fab fa-weixin"></i>
            </span>

            <span class="label">WeChat</span>
          </a>
        </div>
    </div>
  </div>


      <footer class="post-footer">
          
          <div class="post-tags">
              <a href="/tags/js/" rel="tag"><i class="fa fa-tag"></i> js</a>
              <a href="/tags/%E8%AF%AD%E6%B3%95/" rel="tag"><i class="fa fa-tag"></i> 语法</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/12/18/%E8%AE%BE%E7%BD%AE%E9%98%B4%E9%98%B3%E5%B8%88%E6%B8%B8%E6%88%8F%E4%B8%BA%E6%A1%8C%E9%9D%A2%E5%A3%81%E7%BA%B8/" rel="prev" title="设置阴阳师游戏为桌面壁纸">
      <i class="fa fa-chevron-left"></i> 设置阴阳师游戏为桌面壁纸
    </a></div>
      <div class="post-nav-item">
    <a href="/2022/10/04/%E5%86%99%E4%B8%80%E4%B8%AA%E5%85%A8%E7%BD%91%E6%9C%80%E5%85%A8%E7%9A%84%E9%9F%B3%E4%B9%90%E6%92%AD%E6%94%BE%E5%99%A8/" rel="next" title="写一个全网最全的音乐播放器">
      写一个全网最全的音乐播放器 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">
      <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=477844082&auto=1&height=66"></iframe>

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#MusicFree%E6%8F%92%E4%BB%B6%E6%98%AF%E4%BB%80%E4%B9%88"><span class="nav-number">1.</span> <span class="nav-text">MusicFree插件是什么</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%8F%92%E4%BB%B6%E7%9A%84%E6%A0%87%E5%87%86%E5%8D%8F%E8%AE%AE"><span class="nav-number">2.</span> <span class="nav-text">插件的标准协议</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="猫头猫"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">猫头猫</p>
  <div class="site-description" itemprop="description">如果我是一只小猫咪，每天只要喵喵叫。</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">31</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">11</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">27</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/maotoumao" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;maotoumao" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:lhx_xjtu@163.com" title="E-Mail → mailto:lhx_xjtu@163.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">猫头猫</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
    <span title="站点总字数">91k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">1:22</span>
   | <a href="http://beian.miit.gov.cn/" rel="noopener" target="_blank">陕ICP备20005224号-2 </a>
</div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

  

</body>
</html>
